clear all;

% top view region of AVM image
Region_TL_X = 21;
Region_TL_Y = 8;
Region_BR_X = 339;
Region_BR_Y = 466;

% Each camera's position in the top view image (cropped image)
F_CAM_X = 160;  F_CAM_Y = 80;
L_CAM_X = 113;  L_CAM_Y = 161;
R_CAM_X = 208;  R_CAM_Y = 161;
B_CAM_X = 160;  B_CAM_Y = 324;

for i = 3 : 497
    % Load two successive image
    cur_img_name = ['DB\', int2str(i), '.jpg'];
    pre_img_name = ['DB\', int2str(i-2), '.jpg'];
    
    cur_img = rgb2gray(imread(cur_img_name));
    pre_img = rgb2gray(imread(pre_img_name));
    
    diff_img = abs(cur_img - pre_img) + abs(cur_img - pre_img);
    
    % image cropping
    valid_img = diff_img(Region_TL_Y:Region_BR_Y, Region_TL_X:Region_BR_X);
    
    imshow(valid_img); axis on; pause(0.1);
end
